package com.chinasofti.properties;

import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Properties;

public class Demo04 {
    public static void main(String[] args) throws IOException {
        Properties prop = new Properties();
        FileReader fr = new FileReader("java420\\prop.properties");
        prop.load(fr);
        fr.close();
        //System.out.println(prop);
        //获取name和age
        String name=prop.getProperty("name");
        //System.out.println("name = " + name);
       int age = Integer.parseInt(prop.getProperty("age"));
        //System.out.println("age = " + age);
        Student s  =new Student(name,age);
        ObjectOutputStream oos  =new ObjectOutputStream(new FileOutputStream("java420\\a.txt"));
        oos.writeObject(s);
        oos.close();
    }
}
